Hi, I am fetching an attribute called "aVerification" from another module. Some have links are multiple so information fetched is duplicated as a result of mulitple-to-one link. I would like to filter only a single string value and remove the duplication. Note that aVerification attribute has multiple strings, hence enum. Please advise how the code can be modified. Thank you in advance. CODE:
// DXL generated by DOORS traceability wizard on 12 January 2015.
vvsiestaff - Mon Jan 12 12:46:07 EST 2015 |
Re: Remove duplicates values fetched through wizard.
( you can try to replace the 'for l in all ...' loop by something like :
put( skp, s"", s"") ) |
Re: Remove duplicates values fetched through wizard. pommCannelle - Tue Jan 13 04:32:46 EST 2015
( you can try to replace the 'for l in all ...' loop by something like :
put( skp, s"", s"") ) Hi Many thanks for the reply. I have tried this, however no values are displayed only empty cells. Please refer to modified code: //###################################################
// DXL generated by DOORS traceability wizard on 12 January 2015.
|
Re: Remove duplicates values fetched through wizard. vvsiestaff - Tue Jan 13 05:42:56 EST 2015 Hi Many thanks for the reply. I have tried this, however no values are displayed only empty cells. Please refer to modified code: //###################################################
// DXL generated by DOORS traceability wizard on 12 January 2015.
( you should add 's = probeRichAttr_(othero,"aVerification", false)' before the 'put( skp, s, s )' ... |
Re: Remove duplicates values fetched through wizard. pommCannelle - Tue Jan 13 10:23:24 EST 2015
( you should add 's = probeRichAttr_(othero,"aVerification", false)' before the 'put( skp, s, s )' ... Thank you for your advise. Sorry, just tried and it's still showing empty fields. |
Re: Remove duplicates values fetched through wizard. vvsiestaff - Tue Jan 13 10:34:19 EST 2015 Thank you for your advise. Sorry, just tried and it's still showing empty fields. hmmm ... i can't see the last line in your code ... i was expecting the call to showIn ('showIn(obj,1)' ) after it's definition ? |
Re: Remove duplicates values fetched through wizard. pommCannelle - Tue Jan 13 10:58:09 EST 2015 hmmm ... i can't see the last line in your code ... i was expecting the call to showIn ('showIn(obj,1)' ) after it's definition ? Hi, I included showIn(obj,1) now it works.:) However, only for multiple values that are equal . Because values of aVerification is type of enum (muliple selection) duplicates still appear. opt1: values of all objects "n/a". --> Code works fine --> displayed "n/a" opts2: values of objects "n/a" and some "n/a, value2" --> Code not working --> displayed "n/a n/a value1"
|
Re: Remove duplicates values fetched through wizard. vvsiestaff - Tue Jan 13 11:30:25 EST 2015 Hi, I included showIn(obj,1) now it works.:) However, only for multiple values that are equal . Because values of aVerification is type of enum (muliple selection) duplicates still appear. opt1: values of all objects "n/a". --> Code works fine --> displayed "n/a" opts2: values of objects "n/a" and some "n/a, value2" --> Code not working --> displayed "n/a n/a value1"
Well ... the code do exactly what he is supposed to do ;) You can try to add a split function before the showIn definition ... something like : \code
Skip split ( string s, char c ) {
Skip split_string = create
int deb = 0; int i; int index = 0
for ( i=0; i<length(s)-1; i++ ) {
if ( s[i] != c ) continue
put( split_string, index++, s[deb++:i-1] )
}
if ( s[i] == c ) i--
put ( split_string, index, s[deb:i] )
return split_string
}
\code
should do the job... \code
tmp_skp = split(s, '\n')
for tmp_str in tmp_skp do put( skp, tmp_str"", tmp_str"")
delete tmp_skp
\code Of course, you need to add the declarations : \code
Skip tmp_skp = null
string tmp_str = ""
\code
before the 'for l in all(o<-linkModName) do' loop ;) |
Re: Remove duplicates values fetched through wizard. pommCannelle - Wed Jan 14 04:08:32 EST 2015
Well ... the code do exactly what he is supposed to do ;) You can try to add a split function before the showIn definition ... something like : \code
Skip split ( string s, char c ) {
Skip split_string = create
int deb = 0; int i; int index = 0
for ( i=0; i<length(s)-1; i++ ) {
if ( s[i] != c ) continue
put( split_string, index++, s[deb++:i-1] )
}
if ( s[i] == c ) i--
put ( split_string, index, s[deb:i] )
return split_string
}
\code
should do the job... \code
tmp_skp = split(s, '\n')
for tmp_str in tmp_skp do put( skp, tmp_str"", tmp_str"")
delete tmp_skp
\code Of course, you need to add the declarations : \code
Skip tmp_skp = null
string tmp_str = ""
\code
before the 'for l in all(o<-linkModName) do' loop ;) Hi, Thanks for your great support. I think code is nearly working. 1. The updates in my code does not remove the duplicates. 2. Some duplicates have only its first letter removed. 3. And a random value is duplicated.
// DXL generated by DOORS traceability wizard on 12 January 2015.
// Wizard version 2.0, DOORS version 9.3.0.7
pragma runLim, 0
string limitModules[1] = {"4f759a1367885286-00000241"}
int lines[1] = {0}
void adjustLines(int depth, showAtDepth) {
int count
for (count = 0; count < 1; count++) {
while (lines[depth-1] < lines[count]) {
if (depth == showAtDepth) displayRich("\\pard " " ")
lines[depth-1]++
}
}
}
//***********************************************
Skip split ( string s, char c ) {
Skip split_string = create
int deb = 0; int i; int index = 0
for ( i=0; i<length(s)-1; i++ ) {
if ( s[i] != c ) continue
put( split_string, index++, s[deb++:i-1] )
}
if ( s[i] == c ) i--
put ( split_string, index, s[deb:i] )
return split_string
}
//***********************************************
void showIn(Object o, int depth) {
Link l
LinkRef lr
ModName_ otherMod = null
Module linkMod = null
ModuleVersion otherVersion = null
Object othero
string disp = null
string s = null
string plain, plainDisp
int plainTextLen
int count
bool doneOne = false
string linkModName = "*"
for lr in all(o<-linkModName) do {
otherMod = module (sourceVersion lr)
if (!null otherMod) {
if ((!isDeleted otherMod) && (null data(sourceVersion lr))) {
if (!equal(getItem otherMod, (itemFromID limitModules[depth-1]))) continue
load((sourceVersion lr),false)
}
}
}
//******************************
Skip tmp_skp = null
string tmp_str = ""
//****************************
Skip skp = createString()
for l in all(o<-linkModName) do {
otherVersion = sourceVersion l
otherMod = module(otherVersion)
if (null otherMod || isDeleted otherMod) continue
if (!equal(getItem otherMod, (itemFromID limitModules[depth-1]))) continue
othero = source l
if (null othero) {
load(otherVersion,false)
}
othero = source l
if (null othero) continue
if (isDeleted othero) continue
s = probeRichAttr_(othero,"aVerification", false)
//put( skp, s"", s"")
//****************************
tmp_skp = split(s, '\n')
for tmp_str in tmp_skp do put( skp, tmp_str"", tmp_str"")
delete tmp_skp
//****************************
}
string tmp
string string_to_display = ""
for tmp in skp do {
if (string_to_display == "") string_to_display = tmp""
else string_to_display = string_to_display "\n" tmp ""
}
delete skp
displayRich string_to_display
//******************************
}
showIn(obj,1)
|
Re: Remove duplicates values fetched through wizard. vvsiestaff - Wed Jan 14 07:09:54 EST 2015 Hi, Thanks for your great support. I think code is nearly working. 1. The updates in my code does not remove the duplicates. 2. Some duplicates have only its first letter removed. 3. And a random value is duplicated.
// DXL generated by DOORS traceability wizard on 12 January 2015.
// Wizard version 2.0, DOORS version 9.3.0.7
pragma runLim, 0
string limitModules[1] = {"4f759a1367885286-00000241"}
int lines[1] = {0}
void adjustLines(int depth, showAtDepth) {
int count
for (count = 0; count < 1; count++) {
while (lines[depth-1] < lines[count]) {
if (depth == showAtDepth) displayRich("\\pard " " ")
lines[depth-1]++
}
}
}
//***********************************************
Skip split ( string s, char c ) {
Skip split_string = create
int deb = 0; int i; int index = 0
for ( i=0; i<length(s)-1; i++ ) {
if ( s[i] != c ) continue
put( split_string, index++, s[deb++:i-1] )
}
if ( s[i] == c ) i--
put ( split_string, index, s[deb:i] )
return split_string
}
//***********************************************
void showIn(Object o, int depth) {
Link l
LinkRef lr
ModName_ otherMod = null
Module linkMod = null
ModuleVersion otherVersion = null
Object othero
string disp = null
string s = null
string plain, plainDisp
int plainTextLen
int count
bool doneOne = false
string linkModName = "*"
for lr in all(o<-linkModName) do {
otherMod = module (sourceVersion lr)
if (!null otherMod) {
if ((!isDeleted otherMod) && (null data(sourceVersion lr))) {
if (!equal(getItem otherMod, (itemFromID limitModules[depth-1]))) continue
load((sourceVersion lr),false)
}
}
}
//******************************
Skip tmp_skp = null
string tmp_str = ""
//****************************
Skip skp = createString()
for l in all(o<-linkModName) do {
otherVersion = sourceVersion l
otherMod = module(otherVersion)
if (null otherMod || isDeleted otherMod) continue
if (!equal(getItem otherMod, (itemFromID limitModules[depth-1]))) continue
othero = source l
if (null othero) {
load(otherVersion,false)
}
othero = source l
if (null othero) continue
if (isDeleted othero) continue
s = probeRichAttr_(othero,"aVerification", false)
//put( skp, s"", s"")
//****************************
tmp_skp = split(s, '\n')
for tmp_str in tmp_skp do put( skp, tmp_str"", tmp_str"")
delete tmp_skp
//****************************
}
string tmp
string string_to_display = ""
for tmp in skp do {
if (string_to_display == "") string_to_display = tmp""
else string_to_display = string_to_display "\n" tmp ""
}
delete skp
displayRich string_to_display
//******************************
}
showIn(obj,1)
Hey !
I've now access to my computer :)
Skip split ( string s, char c ) {
Skip split_string = create
int deb = 0; int i; int index = 0
for ( i=0; i<length(s)-1; i++ ) {
if ( s[i] != c ) continue
put( split_string, index, s[deb:i-1] )
deb = i+1; index += 1
}
if ( s[i] == c ) i--
put ( split_string, index, s[deb:i] )
return split_string
}
/code I should not try to build code from my smartphone ;D
|
Re: Remove duplicates values fetched through wizard. pommCannelle - Wed Jan 14 09:17:15 EST 2015 Hey !
I've now access to my computer :)
Skip split ( string s, char c ) {
Skip split_string = create
int deb = 0; int i; int index = 0
for ( i=0; i<length(s)-1; i++ ) {
if ( s[i] != c ) continue
put( split_string, index, s[deb:i-1] )
deb = i+1; index += 1
}
if ( s[i] == c ) i--
put ( split_string, index, s[deb:i] )
return split_string
}
/code I should not try to build code from my smartphone ;D
Hi, This code is working great. Many thanks again for your support:) |